package com.example.singletask

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.singletask.util.Task
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class TimerTaskTest {

    @Test
    fun normalTest() {

        var testResult = false

        val timer = Task.timerTask(1000, 200) { timer, tick ->
            println("${Thread.currentThread()} ${timer.isRunning} $tick")
            testResult = tick.counter > 10
        }.runOnThread()

        println("start timer")
        timer.start()

        Thread.sleep(4000)
        timer.stop()

        Assert.assertTrue(testResult)
    }
}